﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Gurucore.DTOGenerator.DTO;

using Antlr.StringTemplate;

namespace Gurucore.DTOGenerator.Business
{
	public class TemplateService
	{
		public string TemplateWeave(string p_sTemplateFile, ClassInfo p_oClassInfo)
		{
			TextReader oTemplateFile = new StreamReader(p_sTemplateFile);			
			string sTemplate = oTemplateFile.ReadToEnd();
			oTemplateFile.Close();

			StringTemplate oStringTemplate = new StringTemplate(sTemplate);
			oStringTemplate.SetAttribute("class", p_oClassInfo);
			oStringTemplate.SetAttribute("properties", p_oClassInfo.Properties.ToArray());
			return oStringTemplate.ToString();
		}
	}
}
